const baseUrl = "http://192.168.4.18"
function http({
    url,
    success
}){
    wx.request({
        url: baseUrl+url,
        header: {'content-type':'application/json'},
        method: 'GET',
        dataType: 'json',
        responseType: 'text',
        success: (result)=>{
            success(result)
        }
    });
}

function getHttpSearch({
    keyword,
    success
}){
    http({
        url:`:3000/search?keywords=${keyword}&type=10`,
        success:res=>{
            success(res)
        }
    })
}

function getHttpList({
    offset,
    success
}){
    http({
        url:`:3000/top/playlist?cat=华语&limit=15&offset=${offset}`,
        success:res=>{
            success(res)
        }
    })
}

function getHttpDetail({
    id,
    success
}){
    http({
        url:`:3000/playlist/detail?id=${id}`,
        success:res=>{
            success(res)
        }
    })
}

function getHttpCart({
    success
}){
    http({
        url:':8000/cart',
        success:res=>{
            success(res)
        }
    })
}
module.exports = {
    getHttpSearch,
    getHttpList,
    getHttpDetail,
    getHttpCart
}